// pages/report_card/report_card.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  back:function(){
    wx.navigateBack({
      
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.request({
      url: app.globalData.url + '/getscore',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        id: app.globalData.udata.id
      },
      success: function (res) {
        if (res.statusCode == 200) {
          that.setData({
            list: res.data,
          })
          if (that.scoreCallback) {
            that.scoreCallback(res)
          }
        } else {
          console.log('res.statusCode != 200   ' + res.errMsg)
        }
      }
    })
    if (that.data.list){
      that.doMore()
    }else{
      that.scoreCallback = res => {
        that.doMore()
      }
    }
  },
  doMore:function(){
    var that = this
    if (that.data.list.list!=undefined) {
      var i = that.data.list.list.length - 1;
      for (; i != -1; i--) {
        var st = 'list.list[' + i + '].tim'
        var time = app.formatUTC(that.data.list.list[i].tim)
        that.setData({ [st]: time })
      }
    } else {
      that.setData({
        list:{list: [
          {tim: '无',
          score: '无'}
        ]}
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})